package com.jy.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jy.mapper.RoomMapper;
import com.jy.pojo.Room;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoomService extends ServiceImpl<RoomMapper, Room> implements IService<Room> {
    @Autowired
    RoomMapper roomMapper;

    public Page findPage(Integer pn, Integer ps, String name) {
        Page<Room> page = new Page<>(pn, ps);
        LambdaQueryWrapper<Room> qw = new LambdaQueryWrapper<>();
        qw.like(StringUtils.isNotEmpty(name), Room::getName, name);
        return roomMapper.selectPage(page, qw);
    }
}
